package concurrency.chapter2;

/**
 * FileName: MyThread
 * Author:   周壮
 * Date:     2020/5/17 17:00
 * Description:
 */
public class MyThread {

    public static int count = 0;

    public static void incr() {
        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        count++;
    }

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 1000; i++) {
            new Thread(() -> MyThread.incr()).start();
        }
        Thread.sleep(3000); //保证线程执行结束 System.out.println("运行结果："+count); }
    }
}